package name.ekr.assetguide;

import java.io.IOException;
import java.text.ParseException;

import name.ekr.assetguide.data.DataLogger;
import name.ekr.assetguide.data.DataProvider;
import name.ekr.assetguide.data.FileDataLogger;
import name.ekr.assetguide.data.PriceIterator;
import name.ekr.assetguide.domain.Portfolio;
import name.ekr.assetguide.services.PortfolioGenerator;

public class AppplicationController {
	
	public static void main(String... args) throws IOException, ParseException, InterruptedException {
		final String INPUT_DATA = "target\\test-classes\\fulldata_from_1999.txt";
		final String YEARLY_STATIC_OUT_DATA = "target\\test-classes\\output.csv";

		final DataLogger log = new FileDataLogger(YEARLY_STATIC_OUT_DATA);
		final PortfolioGenerator generator
			= new PortfolioGenerator(
					new PriceIterator(new DataProvider(INPUT_DATA)),
					log
			);
		
		
		Portfolio portfolio = null;
		generator.generatePortfolios();
		
		log.open();
		while((portfolio = generator.getNextPortfolio()) != null) {
			System.out.println(portfolio);
			portfolio.evaluate();
		}
		log.close();
	}
}
